package day05;
import java.util.Random;
public class MethodDemo2 {
    /*public static void main(String[] args) {
        int a=sum(5,6);
        System.out.println(a);

        int m=7,n=8;
        int b=sum(m,n);
        System.out.println(b);
    }
    public static int sum(int num1,int num2){
        int sum=num1+num2;
        return sum;//返回sum里面的数
        //return num1+num2; 返回num1与num2的和
    }*/
    public static void main(String[] args) {
        int a = sum(6, 6);
        System.out.println(a);

        int m = 7, n = 8;
        int b = sum(m, n);
        System.out.println(b);

        System.out.println("----------------------------");

        int[] c = generateArray(23,23);//模拟第一人使用
        System.out.println("数组的长度：" + c.length);
        for (int i = 0; i < c.length; i++) {
            System.out.println(c[i]);

            int[] d = generateArray(34,56);
            System.out.println("第三个元素的值：" + d[2]);
            for (i = 0; i < d.length; i++) {
                System.out.println(d[i]);
            }
        }

    }

    public static int sum(int num1, int num2) {
        int sum = num1 + num2;
        return sum;

    }

    public static int[] generateArray(int len,int max) {
        Random rand=new Random();
        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = rand.nextInt(max+1);
        }
        return arr;
    }
}



